﻿/*
 * LinearRenderer.GdiStrokeArc
 * 
 * initial implementation : 20.10.2008
 *
 * Copyright (c) Adam Sida, asida@centrum.cz.
 * All rights reserved.
 * 
 * for license see Petra.Gis.License.txt
 */
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Drawing2D;
using Petra.Gis.Geometry;
using Petra.Gis.Geometry.Support;
using Petra.Gis.Geometry.Utils;
//using Petra.Gis.Drawing;
using Petra.Gis.RenderingServices.PlanarBase ;

namespace Petra.Gis.RenderingServices.GDIPlus
{

  public partial class LinearRenderer : EdgeGeomRenderer
  {


    private System.Drawing.PointF[] gdiPlusStrokeArc(Arc geom)
    {
      GraphicsPath _tmpArcStrokePath = new GraphicsPath();

      //System.Drawing.Point arcScreenCenter = _transfMatrix.transformPoint(geom.centerPoint);
      //int arcScreenRadius = _transfMatrix.transformScalar(geom.radius);
      ReadonlyCoordinate arcScreenCenter = geom.centerPoint;
      double arcScreenRadius = geom.radius;

      float startAngle = (float)ArcMath.GetAngleByVector((geom.coordList.startPoint.X - geom.centerPoint.X), (geom.coordList.startPoint.Y - geom.centerPoint.Y));
      float endAngle = (float)ArcMath.GetAngleByVector((geom.coordList.endPoint.X - geom.centerPoint.X), (geom.coordList.endPoint.Y - geom.centerPoint.Y));

      //if ccw arc, swap angles
      if (endAngle - startAngle < 0) { float tmp; tmp = endAngle; endAngle = startAngle; startAngle = tmp; }

      _tmpArcStrokePath.AddArc(
                     ((float)(arcScreenCenter.X - arcScreenRadius)), //start point X
                     ((float)(arcScreenCenter.Y - arcScreenRadius)), //start point Y
                     ((float)(arcScreenRadius + arcScreenRadius)),   //width
                     ((float)(arcScreenRadius + arcScreenRadius)),   //height
                      startAngle, (endAngle - startAngle));          //startangle, endangle

      _tmpArcStrokePath.Flatten();

      return _tmpArcStrokePath.PathPoints;
    }

  }
}
